<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Rapidly Exploring Random Tree (RRT) Global Path Planner Plugin: Converting Maps from Gazebo .world Files to YAML Format</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Rapidly Exploring Random Tree (RRT) Global Path Planner Plugin
   </div>
   <div id="projectbrief">Global path planner plugin for ROS Kinetic Kame that uses the RRT algorithm</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('md_docs_MAP_CONVERSION.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Converting Maps from Gazebo .world Files to YAML Format </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>One of the requirements for this project was to provide a demo in Gazebo. Unfortunately there isn't a clean way (that I have found) to create a world in Gazebo and have it work with the costmaps required in the navigation stack.</p>
<p>Overall, what I did was to create a world in Gazebo. I used the building editor to create a simplified maze and then saved it as a .world file. To do the conversion I used a simulated Turtlebot3 and the packaged SLAM algorithm to drive around the map and map it in Rviz.</p>
<p>Unfortunately, this method does require you spend some time driving your robot around using the teleop until you are satisfied with your map.</p>
<div class="image">
<img src="images/simple_maze_gazebo.png"  alt="alt tag" title="Gazebo Simple Maze world"/>
</div>
<p>The method I used came from the Turtlebot3 <a href="http://turtlebot3.readthedocs.io/en/latest/index.html">tutorials</a> and worked on Ubuntu 16.04 running ROS Kinetic Kame.</p>
<h2>Installing Turtlebot3</h2>
<ol type="1">
<li>The first step in installing Turtlebot3 is to install all of the dependencies. In a terminal window: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation</div></div><!-- fragment --></li>
<li>The next step is to install the Turtlebot3 package <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cd ~/catkin_ws/src/</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;git clone https://github.com/ROBOTIS-GIT/turtlebot3.git</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;cd ~/catkin_ws &amp;&amp; catkin_make</div></div><!-- fragment --></li>
</ol>
<p>Full instructions can be found <a href="http://turtlebot3.robotis.com/en/latest/pc_software.html#install-dependent-packages">here</a>.</p>
<h2>Running Turtlebot3 SLAM</h2>
<p>Once I created my .world file in Gazebo, I modified the turtlebot3_world.launch file to point to the map I had created instead of the default map.</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">launch</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;model&quot;</span> <span class="keyword">default</span>=<span class="stringliteral">&quot;$(env TURTLEBOT3_MODEL)&quot;</span> <span class="keyword">doc</span>=<span class="stringliteral">&quot;model type [burger, waffle]&quot;</span>/&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;x_pos&quot;</span> <span class="keyword">default</span>=<span class="stringliteral">&quot;-2.0&quot;</span>/&gt;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;  &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;y_pos&quot;</span> <span class="keyword">default</span>=<span class="stringliteral">&quot;-0.5&quot;</span>/&gt;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;  &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;z_pos&quot;</span> <span class="keyword">default</span>=<span class="stringliteral">&quot;0.0&quot;</span>/&gt;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;  &lt;<span class="keywordtype">node</span> <span class="keyword">pkg</span>=<span class="stringliteral">&quot;tf&quot;</span> <span class="keyword">type</span>=<span class="stringliteral">&quot;static_transform_publisher&quot;</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;camera_tf&quot;</span> <span class="keyword">args</span>=<span class="stringliteral">&quot;-1.95 -0.55 2.0 -1.58 0 -1.58 /odom /camera_link 100&quot;</span>/&gt;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;  &lt;<span class="keywordtype">include</span> <span class="keyword">file</span>=<span class="stringliteral">&quot;$(find gazebo_ros)/launch/empty_world.launch&quot;</span>&gt;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;    &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;world_name&quot;</span> <span class="keyword">value</span>=<span class="stringliteral">&quot;[PATH TO YOUR WORLD FILE HERE]&quot;</span>/&gt;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;paused&quot;</span> <span class="keyword">value</span>=<span class="stringliteral">&quot;false&quot;</span>/&gt;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;    &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;use_sim_time&quot;</span> <span class="keyword">value</span>=<span class="stringliteral">&quot;true&quot;</span>/&gt;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;    &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;gui&quot;</span> <span class="keyword">value</span>=<span class="stringliteral">&quot;true&quot;</span>/&gt;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;headless&quot;</span> <span class="keyword">value</span>=<span class="stringliteral">&quot;false&quot;</span>/&gt;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    &lt;<span class="keywordtype">arg</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;debug&quot;</span> <span class="keyword">value</span>=<span class="stringliteral">&quot;false&quot;</span>/&gt;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;  &lt;/<span class="keywordtype">include</span>&gt;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;  &lt;<span class="keywordtype">param</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;robot_description&quot;</span> <span class="keyword">command</span>=<span class="stringliteral">&quot;$(find xacro)/xacro.py $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro&quot;</span> /&gt;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;  &lt;<span class="keywordtype">node</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;spawn_urdf&quot;</span> <span class="keyword">pkg</span>=<span class="stringliteral">&quot;gazebo_ros&quot;</span> <span class="keyword">type</span>=<span class="stringliteral">&quot;spawn_model&quot;</span> <span class="keyword">args</span>=<span class="stringliteral">&quot;-urdf -model turtlebot3_burger -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description&quot;</span> /&gt;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;&lt;/<span class="keywordtype">launch</span>&gt;</div></div><!-- fragment --><p> Once you have modified the launch file so that your world is in place, launch the Turtlebot3.</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;export TURTLEBOT3_MODEL=burger</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;roslaunch turtlebot3_gazebo turtlebot3_world.launch</div></div><!-- fragment --><p> To launch the SLAM algorithm: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;export TURTLEBOT3_MODEL=burger</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;roslaunch turtlebot3_slam turtlebot3_slam.launch</div></div><!-- fragment --><p> To show the RViz visualization: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;rosrun rviz rviz -d `rospack find turtlebot3_slam`/rviz/turtlebot3_slam.rviz</div></div><!-- fragment --><p> To launch the keyboard teleoperation: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch</div></div><!-- fragment --><p> Now you just drive it around until you're happy with how the map looks in RViz. </p><div class="image">
<img src="images/simple_maze_2d.png"  alt="alt tag" title="RViz Simple Maze"/>
</div>
 <h2>Saving Your Map</h2>
<p>Open a new terminal window: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;rosrun map_server map_saver -f ~/map</div></div><!-- fragment --><p> Replace <code>~/map</code> with the filename you would like to save your map as. For example, <code>~/simple_maze</code> will give you a <code>simple_maze.pgm</code> and <code>simple_maze.yaml</code>. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
